<?php
// +----------------------------------------------------------------------
// | zhanshop-cloud / FFmpeg.php    [ 2025/8/7 13:56 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2025 zhangqiquan All rights reserved.
// +----------------------------------------------------------------------
// | Author: zhangqiquan <768617998@qq.com>
// +----------------------------------------------------------------------
declare (strict_types=1);

namespace app\api\mcp\v1\controller;

use app\api\mcp\v1\service\FFmpegService;
use app\library\BaseController;
use zhanshop\App;
use zhanshop\server\Request;
use zhanshop\server\Response;
use zhanshop\server\response\mcp\Message;

class Ffmpeg extends BaseController
{
    /**
     * @api POST convert 格式转换
     * @apiParam string file 转换的文件
     * @apiParam string format 目标格式
     * @apiSuccess string file 转换后的文件file
     * @apiSuccess string size 转换后的文件大小
     * @apiDescription 帮我将file转换成format格式
     * @apiGroup 音频视频
     */
    public function postConvert(Request $request, Response $response)
    {
        $data = $request->validateRule([
            'file' => 'required | url',
            'format' => 'required | string',
        ])->getData();

        $message = new Message($request, $response);
        $message->addText(App::make(FFmpegService::class)->postConvert($data['file'], $data['format']));
        //$message->addImage('/Users/zhangqiquan/Documents/phpdev/zhanshop-mcp/public/apiDoc/images/profile.png', "测试图片");
        //$message->addAudio('/Users/zhangqiquan/Downloads/231753845516.9540888483.aac', "测试音频");
        $message->send();
    }
}